#!/usr/bin/perl -w

# perlfold
# File ID: 5869cb92-5d42-11df-bb0e-90e6ba3022ac
# Inserts fold marks in perl source before and after stdin.
# Select text in visual line mode and filter the block through this script.

use strict;

$| = 1;

my $Line = <STDIN>;
my ($Indent, $Title) = ("", "");

defined($ARGV[0]) && ($Title = join(" ", @ARGV) . " ");
$Line =~ /^(\s+)/ && ($Indent = $1);
print("$Indent# $Title\x7B\x7B\x7B\n$Line");

while (<STDIN>) {
	print($_);
}

print("$Indent# \x7D\x7D\x7D\n");
